package com.ygxsk.carhome.views;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;

/**
 * Autuhor:Administrator
 * Time:2020/1/20 0020  17:04
 * Description: this is 为替换 webView 报错
 */
public class X5WebView extends com.tencent.smtt.sdk.WebView {

    public X5WebView(Context context) {
        super(getFixedContext(context));
    }

    public X5WebView(Context context, AttributeSet attrs) {
        super(getFixedContext(context), attrs);
    }

    public X5WebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(getFixedContext(context), attrs, defStyleAttr);
    }

    private static Context getFixedContext(Context context) {
        // Android Lollipop 5.0 & 5.1
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            return context.createConfigurationContext(new Configuration());
        }
        return context;
    }
}
